package com.wushi.lenovo.asia5b.app_ui.h5;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;

import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.h5.H5Bean;
import com.wushi.lenovo.asia5b.app_model.h5.H5TitleBean;
import com.wushi.lenovo.asia5b.app_utils.helper.H5Hepler;
import com.wushi.lenovo.asia5b.app_widget.status.StatusHeightView;

import butterknife.BindView;
import timber.log.Timber;

/**
 * Created by zhangyuncai on 2019/9/17.
 * 自营商城
 */
public class LocalMallActivity extends CategoryActivity {

    public static void startLocalMallActivity(Context context, String url, String title) {
        url = H5Hepler.addAsiaH5Params(url);
        Intent intent = new Intent(context, LocalMallActivity.class);
        intent.putExtra(H5_URL, url);
        if (!TextUtils.isEmpty(title)) {
            intent.putExtra(H5_TITLE, title);
        }
        context.startActivity(intent);
    }

    @BindView(R.id.status_localmall)
    StatusHeightView status_localmall;

    @Override
    protected int getLayoutId() {
        setStatusTrans();
        return R.layout.activity_localmall;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        rl_title.setBackgroundColor(Color.TRANSPARENT);
    }

    @Override
    protected void callBackByJs(H5Bean h5Bean) {
        super.callBackByJs(h5Bean);
        if (h5Bean != null) {
            if (h5Bean instanceof H5TitleBean) {
                H5TitleBean titleBean = (H5TitleBean) h5Bean;
                if (tv_title_titletext != null) {
                    tv_title_titletext.setText(titleBean.getText());
                }
                if (!TextUtils.isEmpty(titleBean.getBgColor())) {
                    setTitleBackColor(titleBean.getBgColor());
                }
            }
        }
    }

    protected void setTitleBackColor(String color) {
        try {
            int iColor = Color.parseColor(color);
            Timber.d("--->>>>>>>>---iColor:"+iColor);
            status_localmall.setBackgroundColor(iColor);
            rl_title.setBackgroundColor(iColor);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
